
import 'osc_user.dart';

class OscSearchResultEntity {
	String prevPageToken;
	String nextPageToken;
	int softwareCount;
	List<OscSearchArticle> softWares;
	int articleCount;
	List<OscSearchArticle> articles;
	int userCount;
	List<OscUser> users;

	OscSearchResultEntity({this.prevPageToken, this.softWares, this.userCount, this.nextPageToken, this.softwareCount, this.articleCount, this.articles, this.users});

	OscSearchResultEntity.fromJson(Map<String, dynamic> json) {
		prevPageToken = json['prevPageToken'];
		if (json['softwares'] != null) {
			softWares = new List<OscSearchArticle>();(json['softwares'] as List).forEach((v) { softWares.add(new OscSearchArticle.fromJson(v)); });
		}
		userCount = json['userCount'];
		nextPageToken = json['nextPageToken'];
		softwareCount = json['softwareCount'];
		articleCount = json['articleCount'];
		if (json['articles'] != null) {
			articles = new List<OscSearchArticle>();(json['articles'] as List).forEach((v) { articles.add(new OscSearchArticle.fromJson(v)); });
		}
		if (json['users'] != null) {
			users = new List<OscUser>();(json['users'] as List).forEach((v) { users.add(new OscUser.fromJson(v)); });
		}
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		data['prevPageToken'] = this.prevPageToken;
		if (this.softWares != null) {
      data['softwares'] =  this.softWares.map((v) => v.toJson()).toList();
    }
		data['userCount'] = this.userCount;
		data['nextPageToken'] = this.nextPageToken;
		data['softwareCount'] = this.softwareCount;
		data['articleCount'] = this.articleCount;
		if (this.articles != null) {
      data['articles'] =  this.articles.map((v) => v.toJson()).toList();
    }
		if (this.users != null) {
      data['users'] =  this.users.map((v) => v.toJson()).toList();
    }
		return data;
	}
}

class OscSearchArticle {
	List<String> imgs;
	String authorId;
	String title;
	int type;
	String pubDate;
	String url;
	int commentCount;
	String softwareLogo;//
	String authorName;
	int oscId;
	String key;
	int viewCount;
	String desc;

	OscSearchArticle({this.imgs, this.authorId, this.title, this.type, this.pubDate, this.url, this.commentCount, this.softwareLogo, this.authorName, this.oscId, this.key, this.viewCount, this.desc});

	OscSearchArticle.fromJson(Map<String, dynamic> json) {
		imgs = json['imgs']?.cast<String>();
		authorId = json['authorId'];
		title = json['title'];
		type = json['type'];
		pubDate = json['pubDate'];
		url = json['url'];
		commentCount = json['commentCount'];
		softwareLogo = json['softwareLogo'];
		authorName = json['authorName'];
		oscId = json['osc_id'];
		key = json['key'];
		viewCount = json['view_count'];
		desc = json['desc'];
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		if (this.imgs != null) {
      data['imgs'] =  [];
    }
		data['authorId'] = this.authorId;
		data['title'] = this.title;
		data['type'] = this.type;
		data['pubDate'] = this.pubDate;
		data['url'] = this.url;
		data['commentCount'] = this.commentCount;
		data['softwareLogo'] = this.softwareLogo;
		data['authorName'] = this.authorName;
		data['osc_id'] = this.oscId;
		data['key'] = this.key;
		data['view_count'] = this.viewCount;
		data['desc'] = this.desc;
		return data;
	}
}
